package com.ky.facescan.base;

import android.content.Context;

import com.alipay.iot.sdk.APIManager;
import com.alipay.iot.sdk.InitFinishCallback;
import com.ky.facescan.IsvConfig;
import com.ky.facescan.utils.LogUtils;

import java.lang.ref.WeakReference;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FaceFrame {
    public static ExecutorService sFtp;
    private static WeakReference<Context> sContextWeakReference;

    public FaceFrame(Context applicationContext) {
        sContextWeakReference = new WeakReference(applicationContext.getApplicationContext());
    }

    public static Context getAppContext() {
        return sContextWeakReference.get();
    }

    public void initFrame() {
        sFtp = Executors.newFixedThreadPool(10);
        try {
            Runnable runnable = () -> {
                SmileManager.getInstance().init();
            };
            InitFinishCallback initFinishCallback = (b) -> {
                if (b) {
                    (new Thread(runnable)).start();
                    LogUtils.e("FaceFrame", "Smile Sdk 初始化成功");
                } else {
                    LogUtils.e("FaceFrame", "Smile Sdk 初始化失败");
                }
            };
            APIManager.getInstance().initialize(FaceFrame.getAppContext(), IsvConfig.ISV_ID, initFinishCallback);
        } catch (APIManager.APIInitException var3) {
            var3.printStackTrace();
        }

    }
}
